﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WeChat.ViewModel;

namespace WeChat.View
{
    /// <summary>
    /// ChatView.xaml 的交互逻辑
    /// </summary>
    public partial class ChatView : UserControl
    {
        public ChatView()
        {
            InitializeComponent();
            this.DataContext = new ChatViewModel();
        }

        private void OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            TextBox SearchTextBox = sender as TextBox;
            SearchTextBox.Focus();
            SearchTextBox.Text = "";
            CloseSearchButton.Visibility = Visibility.Visible;
        }

        private void CloseSearchButton_Click(object sender, RoutedEventArgs e)
        {
            SearchTextBox.Text = "搜索";
            //TextBox失去焦点
            TraversalRequest request = new TraversalRequest(FocusNavigationDirection.Next);
            SearchTextBox.MoveFocus(request);
            CloseSearchButton.Visibility = Visibility.Hidden;
        }
    }
}
